'use strict';

const Controller = require('egg').Controller;
const fs = require('fs')
class UserController extends Controller {
	async index() {
		const { ctx } = this;
		const { url } = ctx.params;
		const filepath = path.resolve(__dirname, '../static', url)
		const exist = fs.existsSync(filepath);
		if (exist) {
			ctx.body = fs.readFileSync(filepath);
		} else {
			ctx.status = 404
			ctx.body = '404 notFound'
		}
	}
}

module.exports = UserController;
